#!/bin/sh

if [ "$#" -ne 2 ]; then
    echo "$0 ACCOUNTS_FILE PROXY_LIST"
    exit
fi

UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0"
FILE="$1"
PROXY_LIST="$2"

grep -Po "(?<= )[\w\.\-_]+\$" "$FILE" |

while IFS= read -r TOKEN;
do
	(echo '
if [ "$(curl -x "$(shuf -n 1 $1)" -A "$2" -H "Authorization: $3" -H "Content-Type: application/json" "https://discordapp.com/api/v6/users/@me/guilds" 2>/dev/null | grep "\"message\":")" != "" ]; then
	echo "N_OK $3";
else
	echo "OK $3";
fi') | /bin/sh /dev/stdin "$PROXY_LIST" "$UA" "$TOKEN" &

done
